async function processVideoFile(options) {
    const { videoFile, interval } = options;
    const video = document.createElement('video');
    video.src = URL.createObjectURL(videoFile);
    await new Promise(resolve => video.addEventListener('loadedmetadata', resolve));
    
    const duration = video.duration;
    const canvas = document.createElement('canvas');
    canvas.width = video.videoWidth;   // 保持原始分辨率
    canvas.height = video.videoHeight;  // 保持原始分辨率
    const ctx = canvas.getContext('2d');

    const times = [];
    for (let t = interval; t <= duration; t += interval) {
        times.push(t);
    }
    
    // 禁用图像平滑处理
    ctx.imageSmoothingEnabled = false;
    if (ctx.imageSmoothingEnabled !== undefined) { // 浏览器兼容性处理
        ctx.imageSmoothingEnabled = false;
        ctx.imageSmoothingQuality = 'high';
    }

    // 配置高质量编码参数
    const recorderOptions = {
        mimeType: 'video/webm; codecs=vp9',
        videoBitsPerSecond: video.videoWidth * video.videoHeight * 30 // 根据分辨率动态计算
    };

    const stream = canvas.captureStream(0);
    const track = stream.getVideoTracks()[0];
    
    const recorder = new MediaRecorder(stream, recorderOptions); // 应用新配置
    const chunks = [];
    recorder.ondataavailable = (event) => chunks.push(event.data);

    return new Promise((resolve, reject) => {
        recorder.onstop = () => {
            URL.revokeObjectURL(video.src); // 修复内存泄漏
            const blob = new Blob(chunks, { type: 'video/webm' });
            resolve({ blob, fileName: `output_${Date.now()}.webm` });
        };
        recorder.onerror = (error) => reject(new Error(`录制失败: ${error}`));

        recorder.start();

        (async () => {
            for (const time of times) {
                video.currentTime = time;
                await new Promise(resolve => {
                    const handler = () => {
                        video.removeEventListener('seeked', handler);
                        resolve();
                    };
                    video.addEventListener('seeked', handler);
                });
                
                // 精确绘制原始尺寸
                ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
                track.requestFrame();
            }
            recorder.stop();
        })();
    });
}